package com.hky.front_end_monitor.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hky.front_end_monitor.constant.Constants;
import com.hky.front_end_monitor.entity.SysFirstPaint;
import com.hky.front_end_monitor.entity.SysNavigationTiming;
import com.hky.front_end_monitor.service.SysNavigationTimingService;
import com.hky.front_end_monitor.mapper.SysNavigationTimingMapper;
import com.hky.front_end_monitor.utils.NumberUtils;
import org.springframework.stereotype.Service;

import java.util.LinkedHashMap;
import java.util.Map;

/**
* @author hello
* @description 针对表【sys_navigation_timing】的数据库操作Service实现
* @createDate 2022-07-28 22:40:40
*/
@Service
public class SysNavigationTimingServiceImpl extends ServiceImpl<SysNavigationTimingMapper, SysNavigationTiming>
    implements SysNavigationTimingService{

    @Override
    public boolean storeNT(String uuid, Map map) {
        SysNavigationTiming NT = new SysNavigationTiming();
        NT.setSysNavigationTimingId(uuid);
        Map data = ((Map) (map.get(Constants.metricsName.NT.value)));
        NT.setFp(NumberUtils.toDouble(data.get("FP")));
        NT.setTti(NumberUtils.toDouble(data.get("TTI")));
        NT.setDomReady(NumberUtils.toDouble(data.get("DomReady")));
        NT.setLoadNt(NumberUtils.toDouble(data.get("Load")));
        NT.setFirstByte(NumberUtils.toDouble(data.get("FirstByte")));
        NT.setDnsNt(NumberUtils.toDouble(data.get("DNS")));
        NT.setTcp(NumberUtils.toDouble(data.get("TCP")));
        NT.setSslNt(NumberUtils.toDouble(data.get("SSL")));
        NT.setTtfb(NumberUtils.toDouble(data.get("TTFB")));
        NT.setTrans(NumberUtils.toDouble(data.get("Trans")));
        NT.setDomParse(NumberUtils.toDouble(data.get("DomParse")));
        NT.setRes(NumberUtils.toDouble(data.get("Res")));
        return this.save(NT);
    }
}




